package com.eazy.lksy.utils;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jzx
 * @desc http 请求处理工具类
 * @date 2016/2/6
 */
@SuppressWarnings("unchecked")
public class ActionRequest {
	
	public static Map<String, String> actionRequest(HttpServletRequest request) {
			Map<String, String> hashMap = new HashMap<String, String>();
			Map<String, String[]> map = request.getParameterMap();
			Set<String> keySet = map.keySet();
			for (String key : keySet) {
				String[] values = map.get(key);
				for (String value : values) {
					hashMap.put(key, value);
				}
			}
			return hashMap;
	}

	public static void setAttr(HttpServletRequest request, String key, Object value) {
		request.setAttribute(key, value);
	}

	public static void setAttrs(HttpServletRequest request, Map<String, Object> map) {
		for (Map.Entry<String, Object> m : map.entrySet()) {
			request.setAttribute(m.getKey(), m.getValue());
		}
	}

	public static void resultJson(HttpServletResponse response) {
	}

	public static String getPara(String name, HttpServletRequest request) {
		return request.getParameter(name);
	}
	
}
